import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.EmptyBorder;


public class PracownikGUI extends JFrame {
	
	private Pracownik p;

	private JPanel contentPane;
	private JTextField textField_imie;
	private JTextField textField_nazwisko;
	private JTextField textField_pesel;
	private JPasswordField passwordField_akt_haslo;
	private JPasswordField passwordField_nowe_haslo;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	 DateFormat formatter ;


	public PracownikGUI(Pracownik p) {
		this.p=p;
		setTitle("Edycja");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 376, 489);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		JLabel label = new JLabel("Imi\u0119:");
		label.setFont(new Font("Tahoma", Font.PLAIN, 17));
		
		textField_imie = new JTextField( 10);
		textField_imie.setFont(new Font("Tahoma", Font.PLAIN, 17));
		textField_imie.setText(p.getImiePracownika());
		
		JLabel label_1 = new JLabel("Nazwisko:");
		label_1.setFont(new Font("Tahoma", Font.PLAIN, 17));
		
		textField_nazwisko = new JTextField( 10);
		textField_nazwisko.setFont(new Font("Tahoma", Font.PLAIN, 17));
		textField_nazwisko.setText(p.getNazwiskoPracownika());
		
		JLabel label_7 = new JLabel("Pesel:");
		label_7.setFont(new Font("Tahoma", Font.PLAIN, 17));
		
		textField_pesel = new JTextField( 10);
		textField_pesel.setFont(new Font("Tahoma", Font.PLAIN, 17));
		textField_pesel.setText(p.getPesel());

		
		JLabel lblAktualneHaso = new JLabel("Aktualne has\u0142o:");
		lblAktualneHaso.setFont(new Font("Tahoma", Font.PLAIN, 17));
		
		passwordField_akt_haslo = new JPasswordField();
		passwordField_akt_haslo.setFont(new Font("Tahoma", Font.PLAIN, 17));
		passwordField_akt_haslo.setColumns(12);
		passwordField_akt_haslo.setText(p.getHaslo());
		
		JLabel lblNoweHaso = new JLabel("Nowe has\u0142o:");
		lblNoweHaso.setFont(new Font("Tahoma", Font.PLAIN, 17));
		
		passwordField_nowe_haslo = new JPasswordField();
		passwordField_nowe_haslo.setFont(new Font("Tahoma", Font.PLAIN, 17));
		passwordField_nowe_haslo.setColumns(12);
		
		JButton btnAnuluj = new JButton("Anuluj");
		btnAnuluj.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				PracownikGUI.this.dispose();
			}
		});
		btnAnuluj.setFont(new Font("Tahoma", Font.PLAIN, 12));
		
		JButton btnOk = new JButton("OK");
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				PracownikGUI.this.dispose();
			}
		});
		btnOk.setFont(new Font("Tahoma", Font.PLAIN, 12));
		
		JLabel lblId = new JLabel("ID:");
		lblId.setFont(new Font("Tahoma", Font.PLAIN, 17));
		
		textField = new JTextField(10);
		textField.setEditable(false);
		textField.setFont(new Font("Tahoma", Font.PLAIN, 17));
		String aString = Integer.toString(p.getIdPracownika());
		textField.setText(aString);
		
		JLabel lblStanowisko = new JLabel("Stanowisko:");
		lblStanowisko.setFont(new Font("Tahoma", Font.PLAIN, 17));
		
		JLabel lblDataZatrudnienia = new JLabel("Data zatrudnienia:");
		lblDataZatrudnienia.setFont(new Font("Tahoma", Font.PLAIN, 17));
		
		textField_1 = new JTextField(10);
		textField_1.setEditable(false);
		textField_1.setFont(new Font("Tahoma", Font.PLAIN, 17));
		String bString = Integer.toString(p.getStanowisko());
		textField_1.setText(bString);
		
		textField_2 = new JTextField(10);
		textField_2.setEditable(false);
		textField_2.setFont(new Font("Tahoma", Font.PLAIN, 17));
		formatter = new SimpleDateFormat("dd-MMM-yy");
		  String s = formatter.format(p.getDataZatrudnienia());
		  textField_2.setText(s);
		
		
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
									.addComponent(btnOk, GroupLayout.PREFERRED_SIZE, 127, GroupLayout.PREFERRED_SIZE)
									.addComponent(label, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
									.addGroup(gl_contentPane.createSequentialGroup()
										.addComponent(lblAktualneHaso, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
										.addPreferredGap(ComponentPlacement.RELATED)))
								.addGroup(gl_contentPane.createSequentialGroup()
									.addComponent(lblNoweHaso, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(ComponentPlacement.RELATED)))
							.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
								.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
									.addGroup(gl_contentPane.createSequentialGroup()
										.addGap(34)
										.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
											.addComponent(textField_nazwisko, GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
											.addComponent(textField_imie, GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
											.addComponent(textField_1, GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
											.addComponent(textField_2, GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
											.addComponent(textField_pesel, GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
											.addComponent(passwordField_akt_haslo, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE)
											.addComponent(textField, GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE))
										.addContainerGap())
									.addGroup(gl_contentPane.createSequentialGroup()
										.addPreferredGap(ComponentPlacement.RELATED)
										.addComponent(btnAnuluj, GroupLayout.PREFERRED_SIZE, 127, GroupLayout.PREFERRED_SIZE)
										.addGap(42)))
								.addGroup(gl_contentPane.createSequentialGroup()
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(passwordField_nowe_haslo, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE)
									.addContainerGap())))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(label_1, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE)
							.addContainerGap(264, Short.MAX_VALUE))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(lblId, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
							.addContainerGap(301, Short.MAX_VALUE))
						.addComponent(label_7, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(lblStanowisko, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)
							.addContainerGap())
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(lblDataZatrudnienia, GroupLayout.PREFERRED_SIZE, 149, GroupLayout.PREFERRED_SIZE)
							.addContainerGap())))
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(lblId, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
						.addComponent(textField, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(label, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
						.addComponent(textField_imie, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(label_1, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
						.addComponent(textField_nazwisko, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(18)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblStanowisko, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
								.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
							.addGap(18)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblDataZatrudnienia, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
								.addComponent(textField_2, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
							.addGap(18)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(label_7, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
								.addComponent(textField_pesel, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
							.addGap(18)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblAktualneHaso)
								.addComponent(passwordField_akt_haslo, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
							.addGap(18)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNoweHaso, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
								.addComponent(passwordField_nowe_haslo, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
							.addGap(45)
							.addComponent(btnOk, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))
						.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
							.addComponent(btnAnuluj, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)))
					.addContainerGap(15, Short.MAX_VALUE))
		);
		contentPane.setLayout(gl_contentPane);
	}
}
